package validate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author langtustupid
 */
public class CheckForm {
   
//Method check a field is username or not
    public static boolean isPwdUsername(String Value) {
        Pattern pattern = Pattern.compile("\\w+");
        Matcher matcher = pattern.matcher(Value);
        if (!matcher.find()) {
            return false;
        } else {
            return true;
        }
    }


    //Check a string is numberic
    public static boolean isNumberic(String value) {
        Pattern pattern = Pattern.compile("\\d+");
        Matcher matcher = pattern.matcher(value);
        if (!matcher.find()) {
            return false;
        } else {
            return true;
        }
    }


    //Validate email input
    public static boolean checkEmail(String value) {
        Pattern pattern = Pattern.compile("[a-zA-Z][_]*\\d*@[a-z]{2,5}[.][a-z]{2,3}");
        Matcher matcher = pattern.matcher(value);
        if (!matcher.find()) {
            return false;
        } else {
            return true;
        }
    }

    //Validate phone number
    public static boolean checkPhoneNumber(String value) {
        Pattern pattern = Pattern.compile("[0]{1}[1,9]{1}[0-9]{8,9}");
        Matcher matcher = pattern.matcher(value);
        if (!matcher.find()) {
            return false;
        } else {
            return true;
        }
    }
}

